void merge (char *sorted_file_1, int sorted_file_1_size, char *sorted_file_2, int sorted_file_2_size, char *merged_file)
{
	int i = 0, j = 0, file1_num, file2_num;
	FILE *ifp1, *ifp2, *ofp;

	ifp1 = fopen (sorted_file_1, "r");
	ifp2 = fopen (sorted_file_2, "r");
	ofp = fopen (merged_file, "w");

	fscanf (ifp1, "%d\n", &file1_num);
	fscanf (ifp2, "%d\n", &file2_num);

	while ((i < sorted_file_1_size) && (j < sorted_file_2_size)) {
		if (file1_num <= file2_num) {
			fprintf (ofp, "%d\n", file1_num);
			fscanf (ifp1, "%d\n", &file1_num);
			i++;
		}
		else {
			fprintf (ofp, "%d\n", file2_num);
			fscanf (ifp2, "%d\n", &file2_num);
			j++;
		}
	}



//These two blocks indicate one of the files has been completely merged. Thus, we put all the remaining numbers from the other file right away.
	if (i < sorted_file_1_size) {
		for (; i < sorted_file_1_size; i++) {
			fprintf (ofp, "%d\n", file1_num);
			fscanf (ifp1, "%d\n", &file1_num);
		}
	}

	if (j < sorted_file_2_size) {
		for (; j < sorted_file_2_size; j++) {
			fprintf (ofp, "%d\n", file2_num);
			fscanf (ifp1, "%d\n", &file2_num);
		}
	}

	fclose(ifp1);
	fclose(ifp2);
	fclose(ofp);
}
